package com.atguigu.memento2;

/**
 * 测试类
 */
public class Client {

	public static void main(String[] args) {
		// 原发人
		OriginatorForUserInfo originator = new OriginatorForUserInfo();
		
		// 负责人
		Caretaker caretaker = new Caretaker();

		originator.setQqNumber("11111");
		originator.setNickname("奋斗");
		originator.setPic("周杰伦的头像");
		show(originator, "初始状态");
		// 保存状态
		caretaker.saveMemento(originator.createMemento());
		
		// 修改密码和电话号码
		originator.setNickname("鹿娘娘");
		originator.setPic("李现的头像");
		show(originator, "修改状态后");

		// 恢复状态一
		originator.restoreMemento(caretaker.getMemento());
		show(originator, "恢复到初始状态后");

	}

	private static void show(OriginatorForUserInfo originator, String status) {
		System.out.println(status + ":");
		originator.show();
		System.out.println("==========================");

	}

}
